package com.kfm.jdbc.day0405;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FixedPool {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(3);

        for (int i = 0; i < 10; i++) {
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + " is running");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            });
        }
        // 关闭线程池
        executorService.shutdown();
        System.out.println("main thread is end");
    }
}
